/**
 * 
 */
package co.fitstart.entity.order;

import com.demo2do.core.utils.Alias;

import co.fitstart.entity.course.Course;

/**
 * 
 * @author mohanlan
 *
 */
@Alias("orderType")
public enum OrderType {
    
    ONLINE("线上", "online"),  //0
    
    INDIVIDUAL("1v1线下减脂营", "individual"),  //1
    
    OTHERS("周边", "others"),   //2
    
    YEAR("年卡", "year"),     //3
    
    GROUP("线下团课", "group"),  //4
    
    ACTIVITY("活动", "activity"),  // 5
    
    SPECIAL("1v1特色课", "special"),  //6
    
    POSTURE("1v1专项体态调整课", "posture"),  //7
    
    CARD("会籍卡", "card");  //8
    
    private String description;
    
    private String alias;
    
    
    OrderType(String description, String alias) {
        this.description = description;
        this.alias = alias;
    }
    
    /**
     * 
     * @param alias
     * @return
     */
    public static OrderType aliasOf(String alias) {
        for (OrderType orderType : OrderType.values()) {
            if (orderType.getAlias().equalsIgnoreCase(alias)) {
                return orderType;
            }
        }
        
        return null;
    }
    
    /**
     * 
     * @param course
     * @return
     */
    public static OrderType determineTo(Course course) {
        if(course == null) {
            return OrderType.OTHERS;
            
        }else if(course != null && course.isOnline()) {
            return OrderType.ONLINE;
            
        } else if(course != null && course.isYear()) {
            return OrderType.YEAR;
            
        } else if(course != null && course.isOffline() && course.isGroup()) {
            return OrderType.GROUP;
            
        } else {
            return OrderType.INDIVIDUAL;
        }
    }
    
    /**
     * 
     * @return
     */
    public boolean isOnline() {
        return this.equals(ONLINE);
    }
    
    /**
     * 
     * @return
     */
    public boolean isOffline() {
        return this.equals(INDIVIDUAL) || this.equals(GROUP) || this.equals(YEAR) || this.equals(SPECIAL) || this.equals(POSTURE) || this.equals(CARD);
    }
    
    /**
     * 
     * @return
     */
    public boolean isIndividual() {
        return this.equals(INDIVIDUAL);
    }
    
    /**
     * 
     * @return
     */
    public boolean isGroup() {
        return this.equals(GROUP);
    }
    
    /**
     * 
     * @return
     */
    public boolean isOthers() {
        return this.equals(OTHERS);
    }
    
    /**
     * 
     * @return
     */
    public boolean isYear() {
        return this.equals(YEAR);
    }
    
    public boolean isActivity() {
        return this.equals(ACTIVITY);
    }
    
    public boolean isPosture() {
        return this.equals(POSTURE);
    }
    
    public boolean isSpecial() {
        return this.equals(SPECIAL);
    }
    
    /**
     * 
     * @return
     */
    public String getDescription() {
        return description;
    }
    
    /**
     * 
     * @return
     */
    public String getAlias() {
        return alias;
    }
    
}
